package jp.co.jspnet.yahata.osgi.eventhandler.twitter;

import org.osgi.framework.BundleActivator;
import org.osgi.framework.BundleContext;
import org.osgi.service.event.EventHandler;

public class Activator implements BundleActivator {

    /*
     * (non-Javadoc)
     * 
     * @see
     * org.osgi.framework.BundleActivator#start(org.osgi.framework.BundleContext
     * )
     */
    public void start(BundleContext context) throws Exception {
        registerEventHandler(context);
    }

    private void registerEventHandler(BundleContext context) throws Exception {

        EventHandlerImpl eventHandlerImpl = new EventHandlerImpl();

        eventHandlerImpl.checkStatus();

        context.registerService(
                EventHandler.class.getName(),
                eventHandlerImpl,
                eventHandlerImpl.getServiceProperties());
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * org.osgi.framework.BundleActivator#stop(org.osgi.framework.BundleContext)
     */
    public void stop(BundleContext context) throws Exception {
        // サービスのunregisterはフレームワークに託す。
    }

}
